package com.example.javamaday.leetcode;

import com.example.javamaday.leetcode.base.TreeNode;

public class LeetCodeTest0104 {

    public static void main(String[] args) {
        TreeNode root = new TreeNode(3);
        root.left = new TreeNode(2);
        int i = new LeetCodeTest0104().maxDepth(root);
        System.out.println(i);
    }

    public int maxDepth(TreeNode root) {
        if (root == null) {
            return 0;
        }
        if (root.right == null && root.left == null) {
            return 1;
        }
        return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1;
    }
}
